/**
 */
package com.logicfish.wpbench2.wpBench.impl;

import com.logicfish.wpbench2.wpBench.ChoiceFn;
import com.logicfish.wpbench2.wpBench.ChoiceParam;
import com.logicfish.wpbench2.wpBench.WpBenchPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Choice Param</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.logicfish.wpbench2.wpBench.impl.ChoiceParamImpl#getChoice <em>Choice</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ChoiceParamImpl extends AbstractParamImpl implements ChoiceParam
{
  /**
   * The cached value of the '{@link #getChoice() <em>Choice</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getChoice()
   * @generated
   * @ordered
   */
  protected ChoiceFn choice;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ChoiceParamImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return WpBenchPackage.Literals.CHOICE_PARAM;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ChoiceFn getChoice()
  {
    return choice;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetChoice(ChoiceFn newChoice, NotificationChain msgs)
  {
    ChoiceFn oldChoice = choice;
    choice = newChoice;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, WpBenchPackage.CHOICE_PARAM__CHOICE, oldChoice, newChoice);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setChoice(ChoiceFn newChoice)
  {
    if (newChoice != choice)
    {
      NotificationChain msgs = null;
      if (choice != null)
        msgs = ((InternalEObject)choice).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - WpBenchPackage.CHOICE_PARAM__CHOICE, null, msgs);
      if (newChoice != null)
        msgs = ((InternalEObject)newChoice).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - WpBenchPackage.CHOICE_PARAM__CHOICE, null, msgs);
      msgs = basicSetChoice(newChoice, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, WpBenchPackage.CHOICE_PARAM__CHOICE, newChoice, newChoice));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case WpBenchPackage.CHOICE_PARAM__CHOICE:
        return basicSetChoice(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case WpBenchPackage.CHOICE_PARAM__CHOICE:
        return getChoice();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case WpBenchPackage.CHOICE_PARAM__CHOICE:
        setChoice((ChoiceFn)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case WpBenchPackage.CHOICE_PARAM__CHOICE:
        setChoice((ChoiceFn)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case WpBenchPackage.CHOICE_PARAM__CHOICE:
        return choice != null;
    }
    return super.eIsSet(featureID);
  }

} //ChoiceParamImpl
